<script type="text/javascript" language="javascript" charset="utf-8">
$(".menu-wrap li").removeClass("active-link");
$(".menu-wrap #service_consultant").addClass("active-link");
</script>
<div class="mask">
</div>
<div class="common-tit">
  <h2>学员列表</h2>
  <span>服务系统 &gt; 学员列表</span>
</div>
<div class="cur-list">
  <div class="cur-listbox clearfix">
    <div class="cur-ll cur-serch clearfix">
      <div class="list-box">
        <div class="downbtn">
          <span data_id="all">请选择消费类型</span>
          <em></em>
        </div>
        <ul class="dropdown-menu">
          <li data_id="all">请选择消费类型</li>
          <li data_id="年卡">年卡</li>
          <li data_id="月卡">月卡</li>
          <li data_id="次卡">次卡</li>
          <li data_id="充值卡">充值卡</li>
        </ul>
      </div>
      <div class="list-box">
        <div class="downbtn">
          <span data_id="all">性别</span>
          <em></em>
        </div>
        <ul class="dropdown-menu">
          <li data_id="all">请选择性别</li>
          <li data_id="男">男</li>
          <li data_id="女">女</li>
        </ul>
      </div>
      <div class="list-box">
        <div class="downbtn">
          <span data_id="all">请选择年龄分组</span>
          <em></em>
        </div>
        <ul class="dropdown-menu">
          <li data_id="all">请选择年龄分组</li>
          <% Company::AGE_GROUP.each do |key, value| %>
            <li data_id="<%= key %>"><%= value %></li>
          <%end%>
        </ul>
      </div>
      <div class="list-box">
        <div class="downbtn">
          <span data_id="all">请选择上课状态</span>
          <em></em>
        </div>
        <ul class="dropdown-menu">
          <li data_id="all">请选择上课状态</li>
          <li data_id="正常">正常</li>
          <li data_id="缺课">缺课</li>
        </ul>
      </div>
      <div class="list-box">
        <div class="downbtn">
          <span data_id="all">缴费状态</span>
          <em></em>
        </div>
        <ul class="dropdown-menu">
          <li data_id="all">缴费状态</li>
          <li data_id="正常">正常</li>
          <li data_id="即将到期">即将到期</li>
        </ul>
      </div>
      <div class="list-box">
        <div class="downbtn">
          <span data_id="all">消费能力</span>
          <em></em>
        </div>
        <ul class="dropdown-menu">
          <li data_id="all">消费能力</li>
          <li data_id="5-10">5-10k</li>
          <li data_id="10-20">10-20k</li>
          <li data_id="20+">20k以上</li>
        </ul>
      </div>
      <div class="i-search">
        <em></em>
        <input id="searchStu" type="text" placeholder="请输入要搜索学员的手机或名字">
      </div>
    </div>
  </div>
  <div class="curlist-con">
    <div class="scrollbox">
      <table>
        <thead>
          <tr>
            <th class="stul-head">头像</th>
            <th class="stul-name">姓名</th>
            <th class="stul-type">消费类型</th>
            <th class="stul-adviser">服务顾问</th>
            <th class="curl-operation">操作</th>
          </tr>
        </thead>
        <tbody>
          <% @students.each do |student| %>
          <tr>
            <td>
              <div class="as-imgbox">
                <img src="" alt="">
              </div>
            </td>
            <td class="stul-name">
              <span><%= student.name %></span>
              <% if student.is_expire %>
              <div>
                <em>即将到期</em>
              </div>
              <%end%>
            </td>
            <td>年卡</td>
            <td><%= student.service_employee.name if student.service_employee_id %></td>
            <td class="curl-operation">
              <span>[</span>
              <em><%= link_to "查看详情", admin_service_consultant_path(student) %></em>
              <span>]</span>
              <span>[</span>
              <em><%= link_to "评价信息", admin_student_student_remarks_path(student) %></em>
              <span>]</span>	
            </td>
          </tr>
          <%end%>
        </tbody>
      </table>
      <div class="apple_pagination">
        <%= paginate @students, :container => false %>
      </div>
    </div>
  </div>
</div>
<script src="/assets/js/common.js"></script>
<script>
$(".cur-ll .list-box li").on("click", function() {
  $(this).parent().parent().find("span").attr("data_id", $(this).attr("data_id"));
  transData();
});
$("#searchStu").change(function() {
  if ($(this).val() != "") {
    transData();
  }
});
function transData() {
  var transD = "";
  for (var i = 0; i < $(".cur-ll .list-box").length; i++) {
    switch(true) {
      case i == 0: transD += "paying_type" + "=" + $($(".cur-ll .list-box")[i]).find("span").attr("data_id") + "&";break;
      case i == 1: transD += "sex" + "=" + $($(".cur-ll .list-box")[i]).find("span").attr("data_id") + "&";break;
      case i == 2: transD += "age_group" + "=" + $($(".cur-ll .list-box")[i]).find("span").attr("data_id") + "&";break;
      case i == 3: transD += "learning_status" + "=" + $($(".cur-ll .list-box")[i]).find("span").attr("data_id") + "&";break;
      case i == 4: transD += "expend_status" + "=" + $($(".cur-ll .list-box")[i]).find("span").attr("data_id") + "&";break;
      case i == 5: transD += "expend_level" + "=" + $($(".cur-ll .list-box")[i]).find("span").attr("data_id");break;
    };
  };
  if ($("#searchStu").val() != "") {
    transD += "&" + "search_student" + "=" + $("#searchStu").val();
  };
  $.ajax({
    type:'get', url:"/admin/service_consultants/get_student_list?"+ transD,
    success: function(data) {
      if (data.error) {
        // console.log("wrong");
      } 
    }
  });
}
</script>
